package com.ulic.customerManApplication.usermodule.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import com.ulic.customerManApplication.base.BaseDao;
import com.ulic.customerManApplication.usermodule.bo.Adminitrator;
import com.ulic.customerManApplication.usermodule.dao.AdminitratorDao;
@Component("adminitratorDao")
public class AdminitratorDaoImpl extends BaseDao implements AdminitratorDao{

	/**
	 * Description: 验证超级管理员登陆
	 * @Version1.0 
	 * 2012-7-10 下午05:58:22 李求智 (liqz@huilan.com) created
	 * @param username
	 * @param password
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public Adminitrator findAdminByPwd(String username, String password) {
		Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
		Criteria cri = session.createCriteria(Adminitrator.class);
		List<Adminitrator> list = cri.add(Restrictions.eq("username", username)).add(Restrictions.eq("password", password)).list();
		Adminitrator admin = null;
		if(list!=null && list.size()==1){
			admin = (Adminitrator)list.get(0);
		}
		return admin;
	}

}
